package com.newland.esp.common.util.SDK;


import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by marco on 2017/8/21.
 * 工具类
 */

public class Tools {
    public static ApiService buildService(String baseUrl) {
        Retrofit retrofit = new Retrofit.Builder().addConverterFactory(GsonConverterFactory.create()).client(new OkHttpClient()).baseUrl(baseUrl)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
        return retrofit.create(ApiService.class);
    }
    //数据解析：GsonConverterFactory
    //配合观察者 RxJavaCallAdapterFactory
    //create: 调用Retrofit实例对象create()方法，传入网络接口类，得到接口对象实例，调用接口类中的方法
    // 参考博客：https://www.jianshu.com/p/f2644cc784f3

}
